﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.ModelConfiguration.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PharmacyBussinesEntities;

namespace PharmacyRepositoy.Mapping
{
    public class CompraMap:EntityTypeConfiguration<Compra>
    {
        public CompraMap()
        {
            this.HasKey(p => p.Id);

            this.Property(p => p.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(p => p.FechaEmicion)
                .IsRequired();
            this.Property(p => p.FechaVencimiento)
                .IsRequired();

            this.Property(p => p.Total)
                .HasPrecision(9, 2);
            this.Property(p => p.Igv)
               .HasPrecision(9, 2);
            this.Property(p => p.ValorBruto)
               .HasPrecision(9, 2);
            this.Property(p => p.ValorNeto)
               .HasPrecision(9, 2);



            this.ToTable("COMPRA");

            this.Property(p => p.Id).HasColumnName("Id");
           
            this.Property(p => p.Total).HasColumnName("Total");

            this.HasRequired(p => p.Proveedor)
                .WithMany(cc => cc.Compras)
                .HasForeignKey(c => c.IdProveedor)
                .WillCascadeOnDelete(false);
        }
    }
}
